<template>
	<view class="page">
		<u-sticky>
			<u-tabs :list="tabbar" :is-scroll="false" :current="current" @change="change"></u-tabs>
		</u-sticky>
	    
		
		
		<view>
			<book :list="list" v-if="list.length" @go="go">
				<template #top="{status}" >
				
					<view style="color: #FF5D39;margin-bottom: 20rpx;font-weight: bold;" v-if="!iselse">
						<text>公益设计</text>
						-
						<text>{{status==2?'设计中':status==6?'已结束':''}}</text>
					</view>
					
					<view  style="color: #FF5D39;margin-bottom: 20rpx;font-weight: bold;"  v-else>
						<text>公益设计-报名成功</text>
					</view>
				</template>
			</book>
		</view>
		
		
		<u-loadmore :status="initial.status" />
	</view>
</template>

<script>
	import loader from '@/common/loadPage.js';
	import book from './components/book.vue';
	
	import {Status} from '@/untils/common.js';
	
	export default {
		mixins: [loader],
		components:{
			book
		},
		data() {

			return {
				tabbar: [
			     {
					name: '已报名',
					state:1
				}, {
					name: '设计中',
					state:2
				}, {
					name: '已结束',
					state:6
				}],
				current: 0,
				list: [],
				initial: {
					geturl: "/indent/orderList",
					parm: {
					 order_type:'11',
					 state:1
					},
					isPage: true
				},
				iselse:''
			}
		},
		watch:{
			current:{
				immediate: true,
				handler(v){
					console.log(v)
					if(!v){
						this.initial.geturl="/user/commonweal";
						this.iselse=true;
						
					}else{
						this.initial.geturl="/indent/orderList";
						this.iselse=false;
					}
					this.getGoods()
				}
			}
		},
	
		async onLoad(options) {
			
			
		},
		methods: {
			change(e){
				this.current=e;
				this.initial.page=1;
				this.initial.parm.state =this.tabbar[e].state;
				
			},
			go(e){
				if(this.iselse){
					this.$u.toast("恭喜中奖，请耐心等待设计师设计")
					return
				}
				uni.navigateTo({
					url:"./public_detail?id="+e.id 
				})
			}
			
			
		}
	}
</script>


<style>
	
	.list{
		background: #fff;
	    width:700rpx;
		 margin: 20rpx auto;
		 padding: 20rpx;
	}
</style>
